from common.baseApi import BaseAPI
from config.Config import Config


class Sgs_Admin_Login(BaseAPI):
    def __init__(self, env='test', host_type='sgs_url'):
        super().__init__(env=env, host_type=host_type)
        self.env = env
        self.config_instance = Config(env)

    def sgs_admin_login(self):
        # Step 1: 获取配置信息
        username = self.config_instance.get_admin_username()
        password = self.config_instance.get_admin_password()

        # Step 4: 发送 login 接口请求
        resp_data = self.requests_send(
            data={
                "username": username,
                "password": password
            })
        return resp_data['accessToken']


if __name__ == '__main__':
    # 创建 Login 实例并调用 login 方法
    login_instance = Sgs_Admin_Login(env='test', host_type='sgs_url')
    res = login_instance.sgs_admin_login()
    print(res)
